package v1

import (
	"fmt"
	"github.com/EDDYCJY/go-gin-example/pkg/e"
	"github.com/EDDYCJY/go-gin-example/pkg/logging"
	"github.com/astaxie/beego/validation"
	"github.com/gin-gonic/gin"
	"net/http"
)

func GetTags(c *gin.Context) {
	name := c.Query("name")
	fmt.Print(name)

	id := c.Query("id")

	valid := validation.Validation{}
	valid.Required(id, "id").Message("id不能为空")
	valid.MaxSize(name, 20, "name").Message("名称不能超过20")
	valid.MinSize(name, 2, "name").Message("名称不能小于2")

	code := e.INVALID_PARAMS
	data := make(map[string]string)
	if !valid.HasErrors() {
		code = e.SUCCESS

	} else {
		for _, err := range valid.Errors {
			logging.Info(err.Key, err.Message)
		}
	}

	c.JSON(http.StatusOK, gin.H{
		"code": code,
		"msg":  e.GetMsg(code),
		"data": data,
	})

}

func AddTags(c *gin.Context) {

}
